﻿/***********************************************************************
 * <copyright file="SqlServerRefTypeDao.cs" company="BUCA JSC">
 * -->    Copyright (C) statement. All right reserved
 * </copyright>
 * 
 * Created:   ThangND
 * Email:    thangnd@buca.vn
 * Website:
 * Create Date: 25 March 2014
 * Usage: 
 * 
 * RevisionHistory: 
 * Date         Author               Description 
 * 
 * ************************************************************************/

using System;
using System.Collections.Generic;
using System.Data;
using BusinessObjects.BussinessDictionary;
using DataObjects.Shared;
using DataObjects.StandartInterfaces.Dictionary;

namespace DataObjects.ADO.SqlServer.Dictionary
{
    /// <summary>
    /// SqlServerRefTypeDao
    /// </summary>
    public class SqlServerRefTypeDao : IRefTypeDao
    {
        /// <summary>
        /// Gets the reference types.
        /// </summary>
        /// <returns></returns>
        public List<RefType> GetRefTypes()
        {
            const string procedures = @"uspGet_All_RefType";
            return Db.ReadList(procedures, CommandType.StoredProcedure, Make);
        }

        /// <summary>
        /// The make
        /// </summary>
        private static readonly Func<IDataReader, RefType> Make = reader =>
           new RefType
           {
               //RefTypeId = reader["RefTypeID"].AsInt(),
                RefTypeId = reader["RefTypeID"].AsInt(),
                MasterTable = reader["RefTypeID"].AsString(),
                Name = reader["RefTypeID"].AsString(),
                DetailTable = reader["RefTypeID"].AsString(),
                Description = reader["RefTypeID"].AsString(),
                IsActive = reader["RefTypeID"].AsBool()
           };
    }
}
